<?php
/**
 * CouponController.class.php
 * 优惠类控制器
 *
 * @author   <王中艺>
 * @date 2017-02-19
 */

namespace Wechat\Controller;

class CouponController extends BaseController {
	/**
	 * 检测优惠码
	 * @param   $code 优惠码
	 * @param   $amount 消费金额
	 * @return  $codeInfo [description]
	 */
	function checkCode(){
		$this->unEmptyParam(array('code', 'amount'));
		$code 	= $this->iInfo['code'];
		$amount = $this->iInfo['amount'];
		$userId 	= C('User.id');

		$codeInfo 	= D('Coupon')->checkCouponCode($code, $userId, $amount);
		if($codeInfo === false)
			$this->outOInfo(D('Coupon')->errMsg, 0);
		$this->outOInfo(array('info' => $codeInfo));
	}
}